<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增数据库导出信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-sbrExpDbInfo-add">
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">数据库信息：</label>
                <div class="col-sm-4">
                    <input name="dbId" type="hidden" id="dbId">
                    <div class="input-group">
                        <input name="dbInfo" onclick="selectDbInfo()" id="dbInfo" type="text" placeholder="请选择待导出的数据库信息" class="form-control" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
                <label class="col-sm-3 control-label is-required">导出数据库类型：</label>
                <div class="col-sm-3">
                    <select name="dbType" class="form-control m-b" th:with="type=${@dict.getType('sbr_database_type')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">表空间名称：</label>
                <div class="col-sm-4">
                    <input name="tableSchema" class="form-control" type="text" required>
                </div>
                <label class="col-sm-3 control-label is-required">是否导出数据：</label>
                <div class="col-sm-3">
                    <select name="exportDataFlag" class="form-control m-b" th:with="type=${@dict.getType('sys_yes_no')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label">导出标识：</label>
                <div class="col-sm-8">
                    <select name="exportFlag" class="form-control m-b" th:with="type=${@dict.getType('sys_common_status')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>-->
            <div class="form-group">    
                <label class="col-sm-2 control-label">备注：</label>
                <div class="col-sm-10">
                    <textarea name="remark" class="form-control"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "sqlbuilder/sbrExpDbInfo"
        $("#form-sbrExpDbInfo-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-sbrExpDbInfo-add').serialize());
            }
        }

        /**选择数据库信息*/
        function selectDbInfo() {
            var url = ctx + "sqlbuilder/sbrDatabase/selectTable";
            var options = {
                title: '选择数据库信息',
                width: "800",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            $("#dbId").val(rows[0].id);
            $("#dbInfo").val(rows[0].name);
            layer.close(index);
        }
    </script>
</body>
</html>